package itheima.com.exam.zy7;

import java.io.*;

public class Test {

    public static void main(String[] args) {
        final long start = System.currentTimeMillis();

        // 使用匿名内部类开启线程
        Thread copyThread = new Thread(new Runnable() {
            @Override
            public void run() {
                // 字符缓冲流一次读写一行
                try (
                        BufferedReader br = new BufferedReader(new FileReader("D:\\javabase_ws\\javaAdvanceProject\\day_17\\src\\itheima\\com\\exam\\zy7\\a.txt"));
                        BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\javabase_ws\\javaAdvanceProject\\day_17\\src\\itheima\\com\\exam\\zy7\\b.txt"))
                ) {
                    String line;
                    while ((line = br.readLine()) != null) {
                        bw.write(line);
                        bw.newLine();   // 换行
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }

                // 记录结束时间并打印耗时
                long end = System.currentTimeMillis();
                System.out.println("复制完成，耗时：" + (end - start) + " 毫秒");
            }
        });

        // 启动线程
        copyThread.start();
    }


    }

